<template>
  <div>
    <MyTable :loading="queryLoading" :cols="cols" :data="list">
      <template v-slot:level="{ row: { level } }">
        <el-tag :type="colors[level]">{{ levels[level] }}级</el-tag>
      </template>
    </MyTable>
  </div>
</template>

<script>
import { getRightsList } from "api/rights";
export default {
  name: "rightList",
  data() {
    return {
      /**
       * 等级
       */
      levels: ["一", "二", "三"],
      /**
       * 颜色
       */
      colors: ["", "success", "warning"],
      /**
       * 列
       */
      cols: [
        {
          title: "#",
          type: "index",
        },
        {
          title: "权限名称",
          name: "authName",
        },
        {
          title: "路径",
          name: "path",
        },
        {
          title: "权限等级",
          slot: "level",
        },
      ],
    };
  },
  created() {
    this.getRights();
  },
  methods: {
    /**
     * 获取权限列表
     */
    async getRights() {
      try {
        this.queryLoading = true;
        this.list = await getRightsList();
      } catch (error) {}
      this.queryLoading = false;
    },
  },
};
</script>

<style scoped >
</style>
